
#include "StdAfx.h"
#include "NvdManager.h"

CNvdManager::CNvdManager(void)
{
}

CNvdManager::~CNvdManager(void)
{
}

BOOL CNvdManager::LoadNvdListFormAas()
{
	Result r = AAS_GetNvdList(theUser->GetUserName(), theUser->GetToken(), theUser->GetMCFlag(), &m_NvdArray);

	if(r.code == AAS_ERROR_SUCCESS)
	{
		NvdInfo info1, info2, info3;/////////////temp
		info1.DeviceName = _T("NVD1");
		info2.DeviceName = _T("NVD2");
		info3.DeviceName = _T("NVD3");
		info1.NvdUid = _T("11:11:11:11:11:11");
		info2.NvdUid = _T("22:22:22:22:22:22");
		info3.NvdUid = _T("30:00:33:33:33:33");
		
		m_NvdArray.push_back(info1);
		m_NvdArray.push_back(info2);
		m_NvdArray.push_back(info3);//////////////temp
		return TRUE;
	}
	else
	{
		//AfxMessageBox(LOAD_STRING(_T("ID_string_page_tvwall_prompt_getnvd_failed")));
		return FALSE;
	}
}

BOOL CNvdManager::UpdateNvdList()
{
	m_NvdArray.empty();
	BOOL ret = LoadNvdListFormAas();
	return ret;
}

BOOL CNvdManager::GetNvdByUid(CString strUid, NvdInfo* pInfo)
{
	vector<NvdInfo>::iterator v1_Iter;
	//int i = 0;
	for (v1_Iter = m_NvdArray.begin(); v1_Iter != m_NvdArray.end(); ++v1_Iter)
	{
		if((*v1_Iter).NvdUid == strUid)
		{
			//*pInfo = m_NvdArray[i];
			*pInfo = (*v1_Iter);
			return TRUE;
		}
		//i++;
	}

	return FALSE;
}